package org.example.design.build01;

import org.example.design.build01.celling.LevelOneCeiling;
import org.example.design.build01.celling.LevelTwoCeiling;
import org.example.design.build01.coat.DuluxCoat;
import org.example.design.build01.coat.LiBangCoat;
import org.example.design.build01.floor.ShengXiangFloor;
import org.example.design.build01.itf.Matter;
import org.example.design.build01.title.DongPengTitle;
import org.example.design.build01.title.MarcoPoloTitle;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @Classname DecorationPackageController
 * @Description TODO
 * @Date 2020/11/2 10:10 上午
 * @Created by xiangjd
 */
public class DecorationPackageController {

    public String getMatterList(BigDecimal area, Integer level) {
        List<Matter> list = new ArrayList<>();
        BigDecimal price = BigDecimal.ZERO;
        //豪华欧式
        if (1 == level) {
            LevelOneCeiling levelOneCeiling = new LevelOneCeiling();//一级顶
            DuluxCoat duluxCoat = new DuluxCoat();//多乐士涂料
            ShengXiangFloor shengXiangFloor = new ShengXiangFloor();//圣象地板
            list.add(levelOneCeiling);
            list.add(duluxCoat);
            list.add(shengXiangFloor);

            price = price.add(area.multiply(new BigDecimal(0.2)).multiply(levelOneCeiling.price()));
            price = price.add(area.multiply(new BigDecimal(1.4)).multiply(duluxCoat.price()));
            price = price.add(area.multiply(shengXiangFloor.price()));
        }
        //轻奢田园
        if (2 == level) {
            //二级吊顶
            LevelTwoCeiling levelTwoCeiling = new LevelTwoCeiling();
            //立邦漆
            LiBangCoat liBangCoat = new LiBangCoat();
            //马可波罗
            MarcoPoloTitle marcoPoloTitle = new MarcoPoloTitle();
            list.add(levelTwoCeiling);
            list.add(liBangCoat);
            list.add(marcoPoloTitle);

            price = price.add(area.multiply(new BigDecimal("0.2")).multiply(levelTwoCeiling.price()));
            price = price.add(area.multiply(new BigDecimal("1.4")).multiply(liBangCoat.price()));
            price = price.add(area.multiply(marcoPoloTitle.price()));
        }

        //现代简约
        if (3 == level) {
            LevelOneCeiling levelOneCeiling = new LevelOneCeiling();  // 吊顶，二级顶
            LiBangCoat liBangCoat = new LiBangCoat();                 // 涂料，立邦
            DongPengTitle dongPengTile = new DongPengTitle();           // 地砖，东鹏

            list.add(levelOneCeiling);
            list.add(liBangCoat);
            list.add(dongPengTile);

            price = price.add(area.multiply(new BigDecimal("0.2")).multiply(levelOneCeiling.price()));
            price = price.add(area.multiply(new BigDecimal("1.4")).multiply(liBangCoat.price()));
            price = price.add(area.multiply(dongPengTile.price()));
        }

        StringBuilder detail = new StringBuilder("\r\n-------------------------------------------------------\r\n" +
                "装修清单" + "\r\n" +
                "套餐等级：" + level + "\r\n" +
                "套餐价格：" + price.setScale(2, BigDecimal.ROUND_HALF_UP) + " 元\r\n" +
                "房屋面积：" + area.doubleValue() + " 平米\r\n" +
                "材料清单：\r\n");

        for (Matter matter : list) {
            detail.append(matter.scene()).append(": ").append(matter.brand()).append("、 ").append(matter.model())
                    .append("、平米价格：").append(matter.price()).append(" 元。\n");
        }
        return detail.toString();
    }
}
